﻿using B.S.Material.Domain.Production_rejection;
using B.S.Material.ErrorCode;
using B.S.Material.Read.Api.Applications.Command.StrippingDetailsCommand;
using MediatR;
using SqlSugar;

namespace B.S.Material.Read.Api.Applications.Handler.StrippingDetailsHandler
{
    public class FTStrippingDetailsHandler : IRequestHandler<FTStrippingDetailsCommand, ApiResult<List<StrippingDetails>>>
    {
        private readonly ISqlSugarClient db;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="db"></param>
        /// <param name="config"></param>
        public FTStrippingDetailsHandler(ISqlSugarClient db)
        {
            this.db = db;

        }
        public async Task<ApiResult<List<StrippingDetails>>> Handle(FTStrippingDetailsCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<StrippingDetails>> result = new ApiResult<List<StrippingDetails>>();
            var list = await db.Queryable<StrippingDetails>().Where(x => x.IsDel == false && x.StrippingDetailsId == request.StrippingDetailsId).ToListAsync();
            result.data = list;
            result.Code = ApiEnum.显示成功;
            result.MAG = ApiEnum.显示成功.ToString();
            return await Task.FromResult(result);
        }
    }
}
